<html>
<head><meta charset="utf-8"><title>MCP: repr(align(ptr)) lang-team#35 · t-lang/major changes · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/index.html">t-lang/major changes</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html">MCP: repr(align(ptr)) lang-team#35</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="203653217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/203653217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#203653217">(Jul 12 2020 at 17:41)</a>:</h4>
<p>I'm debugging why the stream doesn't have an announcement now</p>



<a name="203666490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/203666490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#203666490">(Jul 12 2020 at 23:35)</a>:</h4>
<p>Well it looks like we've got just a topic/thread, within the <code>t-lang/major changes</code> stream, and I don't think there's normally an announcement for just a topic.</p>



<a name="203671078"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/203671078" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#203671078">(Jul 13 2020 at 01:44)</a>:</h4>
<p>rather than adding a special case, what about allowing arbitrary constant expressions? <code>repr(align(size_of::&lt;*const u8&gt;()))</code></p>



<a name="203671181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/203671181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#203671181">(Jul 13 2020 at 01:47)</a>:</h4>
<p>(also, why does AtomicPtr even need explicit alignment? are there any targets where pointers are not naturally aligned already?)</p>



<a name="203671252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/203671252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#203671252">(Jul 13 2020 at 01:49)</a>:</h4>
<p>(yeah I think it'd be a lot better as a repr(transparent) type, but then we can't have this great MCP where we allow const expressions as alignment values)</p>



<a name="203671256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/203671256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#203671256">(Jul 13 2020 at 01:49)</a>:</h4>
<p>lol</p>



<a name="203671302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/203671302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#203671302">(Jul 13 2020 at 01:50)</a>:</h4>
<p>I guess one concern with allowing any const expression is that you could make a depencency loop, but that can just give a compile error with a message.</p>



<a name="203671313"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/203671313" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#203671313">(Jul 13 2020 at 01:51)</a>:</h4>
<p>for prior art, I've used <code>alignas(SOME_CONSTANT)</code> fairly often in C++</p>



<a name="203671608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/203671608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> comex <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#203671608">(Jul 13 2020 at 01:59)</a>:</h4>
<p>…partly for the benefit of getting a compile error if I accidentally include a field with higher alignment, though it looks like Rust doesn't have such a diagnostic yet (<a href="https://github.com/rust-lang/rust/issues/48159">https://github.com/rust-lang/rust/issues/48159</a>)</p>



<a name="204465288"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/204465288" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#204465288">(Jul 20 2020 at 19:28)</a>:</h4>
<p>To add to this one, <code>repr(align(size))</code> might be interesting too, so that <code>#[repr(align(size))] struct Foo(usize, usize);</code> would have align <code>2*ptr</code>.</p>



<a name="204465366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/204465366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#204465366">(Jul 20 2020 at 19:29)</a>:</h4>
<p>Seems logical to have short-hands for the two non-literal common scenarios...</p>



<a name="204479983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/204479983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#204479983">(Jul 20 2020 at 21:43)</a>:</h4>
<p>Hey <span class="user-mention" data-user-id="125270">@scottmcm</span>, I saw you self-assigned to this issue. Is the intent that you'd like to work with <span class="user-mention" data-user-id="224471">@Lokathor</span> on this? </p>
<p>Should we make a project group? (I just mean an issue on the lang-team repo and a stream where folks who are interested can chat, though we could make a repo too if desired.)</p>



<a name="204492652"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/204492652" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#204492652">(Jul 20 2020 at 22:42)</a>:</h4>
<p>Yup; I'll sign up for that.</p>
<p>A whole repo seems like overkill to me, since I don't think this will introduce any new semantics.  I'm not sure what process things are appropriate.</p>



<a name="204496217"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/204496217" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#204496217">(Jul 20 2020 at 23:20)</a>:</h4>
<p>There seem to be a few improvements over my base idea already, so a GitHub issue or Zulip stream seems to be the right start</p>



<a name="204496229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/204496229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#204496229">(Jul 20 2020 at 23:20)</a>:</h4>
<p>or even this topic i guess</p>



<a name="204592920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/204592920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#204592920">(Jul 21 2020 at 19:35)</a>:</h4>
<p>nah let's make a dedicated stream, keep things organized</p>



<a name="205564202"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/205564202" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#205564202">(Jul 31 2020 at 07:16)</a>:</h4>
<p>Is that something I can do?  Or was it created and my zulip-foo just isn't strong enough?</p>
<p>(Sorry for delay, Lokathor, but I'm back from the week at my friend's wedding.)</p>



<a name="205565590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/205565590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#205565590">(Jul 31 2020 at 07:40)</a>:</h4>
<p>the general workflow is now something like:</p>
<ul>
<li>project group charter: FCP to pass and makes a zulip once it's accepted.</li>
<li>project group works up a sturdy RFC</li>
<li>Once the RFC seems sturdy enough it gets posted.</li>
</ul>
<p>The aim is to move the normal RFC discussion out of the PR thread itself and into zulip, where it's easier to follow along conversation topics individually.</p>



<a name="205592464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/205592464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#205592464">(Jul 31 2020 at 13:56)</a>:</h4>
<p>Yeah, I can make the stream, but I was waiting until we had a charter</p>



<a name="205593126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/205593126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#205593126">(Jul 31 2020 at 14:01)</a>:</h4>
<p>I will be writing that later today probably.</p>
<p>I plain aim for the "simple names" that have been proposed (<code>ptr</code> and <code>size</code>), and I think that making it accept any arbitrary const expression is probably a separate, bigger design, that should probably be proposed once const generics and const evaluation in general is far more complete.</p>



<a name="205657301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/205657301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#205657301">(Aug 01 2020 at 01:24)</a>:</h4>
<p><a href="https://hackmd.io/_Gtlwyn0S1CN3VbKYbPNrg">https://hackmd.io/_Gtlwyn0S1CN3VbKYbPNrg</a></p>



<a name="205666754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/205666754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#205666754">(Aug 01 2020 at 06:02)</a>:</h4>
<p>I support keeping it simple <span aria-label="thumbs up" class="emoji emoji-1f44d" role="img" title="thumbs up">:thumbs_up:</span></p>



<a name="205673319"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/205673319" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kennytm <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#205673319">(Aug 01 2020 at 09:21)</a>:</h4>
<blockquote>
<p><code>#[repr(align(size))]</code></p>
</blockquote>
<p>how is this possible? what is <code>#[repr(align(size))] struct Three(u32, u32, u32);</code> ?</p>



<a name="205680641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/205680641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#205680641">(Aug 01 2020 at 13:06)</a>:</h4>
<p>We'll find out once the group is founded and starts it discussions.</p>



<a name="205849432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/205849432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#205849432">(Aug 03 2020 at 21:29)</a>:</h4>
<p><span class="user-mention" data-user-id="125254">@kennytm</span> 4 bytes of padding, same as how <code>#[repr(align(8))] struct One(u32);</code> gets padding.</p>



<a name="205870849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/205870849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> kennytm <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#205870849">(Aug 04 2020 at 03:44)</a>:</h4>
<p><span class="user-mention" data-user-id="125270">@scottmcm</span> so that means the alignment is the original size rounded up to the next power of 2?</p>



<a name="205873863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/205873863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#205873863">(Aug 04 2020 at 05:08)</a>:</h4>
<p>funny, i was thinking it would just error if the size isn't a power of two</p>



<a name="205873875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/205873875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#205873875">(Aug 04 2020 at 05:08)</a>:</h4>
<p>but there's a good reason that was just a bonus idea next to the main idea</p>



<a name="205874599"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20repr%28align%28ptr%29%29%20lang-team%2335/near/205874599" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20repr(align(ptr)).20lang-team.2335.html#205874599">(Aug 04 2020 at 05:30)</a>:</h4>
<p><span class="user-mention" data-user-id="125254">@kennytm</span> That's what I was expecting, yes.  <code>align(8)</code> makes the size as small as possible while still maintaining size=8*n, so <code>align(size)</code> would make the size as small as possible while still maintaining size=align -- and the implementation of that would be to do what you said.</p>
<p>(But as Lokathor says, it's not an essential addition.  Might still get cut.)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>